package com.smsc.headend.task.engine.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CustomMatchUtil {
    public static String getInstanceId(String resultString) {
        Pattern pattern = Pattern.compile("InstanceId.*Value=\"(.*)\"");
        Matcher m = pattern.matcher(resultString);
        if (m.find()) {
            return m.group(1);
        }
        return null;
    }

    public static String getAttributeResult(String resultString) {
        Pattern ptHdlc = Pattern.compile("(?<=<AttributeValue>)(?:(?!</AttributeValue>).)*", Pattern.DOTALL);
        Matcher mHdlc = ptHdlc.matcher(resultString);
        if (mHdlc.find()) {
            return mHdlc.group().replace("\r", "").replace("\n", "").replaceAll("  ", "");
        }

        return null;
    }
}
